<div class="navButtonsTop rounded-corners">
	<h1 class="title"><g:message code="title.page.list" args="[title]"/></h1>
</div>
		
			
<div class="element rounded-corners">
	<g:if test="${pageInstanceList}">
			<g:if test="${session.pageViewMode == 'flow'}">
			<div class="scroll rounded-corners">
	  			<g:each in="${pageInstanceList}" var="pageInstance">
			    	<div class="item ${pageInstance.disabled ? 'disableItem' : ''}">
			    	
			    		<img class="portada" src="${resource(file:pageInstance?.pathFileThumbnail)}" />
			    	
			    		<div class="resumen">
							<label>${pageInstance.title}</label>
						</div>
						
				    	<div class="botones">
							<g:form class="actionDefault" controller="page" action="show">
								<g:hiddenField name="id" value="${pageInstance?.id}"/>
								<g:submitButton class="itemButton showDetails" name="showDetails" value="${message(code:'default.button.details')}" />
							</g:form>
							
							<g:if test="${comicInstance?.alterPages}">	
								<input type="button" class="itemButton show js_run" name="show" value="${message(code:'default.button.play')}" />
							
							    <div class="hidden js_play">
									<g:if test="${pageInstance?.alterPages}">
										<g:set var="orderedPages" value="${pageInstance?.alterPages.sort{it.rate}.reverse()}" />
										<g:each in="${orderedPages}" var="alterPageInstance">
											<a class="lightbox" href="${resource(file:alterPageInstance?.pathFile)}" rel="lightbox[${alterPageInstance.id}]" title="${alterPageInstance?.title}"></a>
										</g:each>	
									</g:if>
								</div>
							</g:if>		
						</div>	
					</div>
				</g:each>
			</div>
		</g:if>
	
		<g:if test="${session.pageViewMode == 'list'}">
			<div class="tableList rounded-corners">
				<table>
		        	<thead>
		            	<tr>
		            		<th><g:message code="default.label.actions"/></th>
		            		<usr:isAdmin>
								<g:sortableColumn property="id" titleKey="default.label.id" params="['fromId':fromId]"/>
								<g:sortableColumn property="disabled" titleKey="default.label.disabled" params="['fromId':fromId]"/>
							</usr:isAdmin>
		               	    <g:sortableColumn property="title" titleKey="default.label.title" params="['fromId':fromId]"/>
		               	    <th><g:message code="default.label.createdBy"/></th>
						</tr>
					</thead>
					<tbody>
		            	<g:each in="${pageInstanceList}" status="i" var="pageInstance">
		                	<tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
		                        <td><g:link action="show" id="${pageInstance.id}"><g:message code="default.label.show"/></g:link></td>
		                        <usr:isAdmin>
			                        <td>${fieldValue(bean: pageInstance, field: "id")}</td>
			                        <td><g:formatBoolean boolean="${pageInstance.disabled}" /></td>
		                        </usr:isAdmin>
		                        <td>${fieldValue(bean: pageInstance, field: "title")}</td>
		                        <td>${fieldValue(bean: pageInstance, field: "createdBy.alias")}</td>
		                    </tr>
		                </g:each>
					</tbody>
				</table>
			</div>
		</g:if>
	</g:if>
	
	<g:else>
		<div class="noData rounded-corners">
			<g:message code="default.no.pages"/>
		</div>
	</g:else>
</div>

<div class="paginateButtons rounded-corners">
	<div class="left">
		<g:paginate total="${pageInstanceTotal}" params="['fromId':fromId]"/>
	</div>
	<div class="right">
		<g:link controller="comic" action="show" id="${params.fromId}"><g:message code="default.button.back"/></g:link>
	</div>		
</div>
